<?php
$this->headTitle('Data index');
$this->headLink()
    ->appendStylesheet($this->STATIC_URL .'/themes/file.css');
?>

<h2>
	<span><?php echo $this->translate('Data index')?></span>
	<a href="<?php echo $this->url(array(
        'action'=> 'import'
        ))?>"><?php echo $this->translate('Import data')?></a>
</h2>

<form id="form1" name="form1" action="" method="post" class="ajaxpost">
<div class="fieldset">
<div class="legend"><span>数据列表</span></div>
<div class="infolist">
<?php foreach ($this->entries as $tablename => $table ) {
	echo '<dl title="表名：'. $tablename .'">',
		'<dt class="'.$table['module'].'"></dt>',
		'<dd><input type="checkbox" name="tables[]" value="'. $tablename .'" />'. $table['title'],
			'<span>记录：'. $table['count']. '</span><span>大小：'. $table['size']. '</span>',
		'</dd>',
	'</dl>';
}?>
</div>
</div>

<div id="QueryResult" class="fieldset collapsed">
<div class="legend"><span>备份列表</span></div>
<ol class="li-icons">
<?php foreach ( $BackupList as $backup ) {
	echo '<li>',
		'<h3><em><a href="'.url( 'data/backup/'.$backup['name'] ).'">'. $backup['name'] .'</a></em></h3>',
		'<h5 class="leaf">导出表数：'. $backup['count'] .'</h5>',
		'<h5 class="leaf">导出日期：'. date( 'Y-m-d H:i:s', $backup['create'] ) .'</h5>',
	'</li>';
}?>
</ol>
</div>

<p>
	<input type="button" id="Select" value="全选" />
	<input type="button" id="Invect" value="反选" />
	<input type="button" onClick="form1.action='<?php echo url( 'data/export' )?>';form1.submit();" value="导出" />
	<input type="submit" name="<?php echo url( 'data/table/repair' )?>" value="修复表" />
	<input type="submit" name="<?php echo url( 'data/table/optimize' )?>" value="优化表" />
</p>
</form>


<style type="text/css">
div.infolist dl dt {
	background-image:url("<?php echo ROOT_DIR?>modules/data/data.png");
}
<?php foreach ( raysn_object( 'file' )->path( './modules/' )->dirs() as $ModuleName ) {
	echo 'div.infolist dl dt.'. $ModuleName .' {background-image:url("'. ROOT_DIR .'modules/'.$ModuleName.'/'.$ModuleName.'.png");}';
}?>
</style>
<script type="text/javascript">
$(function(){
<?php if ( ! empty ( $BackupList ) ) {?>
	$("#QueryResult").addClass("collapsible");
	RaysnWeb.behaviors.collapse( );
<?php }?>
	$("#Select").click(function(){$(':checkbox').attr("checked", true);});
	$("#Invect").click(function(){$(':checkbox').attr("checked", function(){return this.checked? false: true;});});
});
</script>